package com.thp.proxy.custom;

import java.lang.reflect.Method;

import com.thp.proxy.model.Person;
/**
 * 代理类
 * @author Tommy
 *
 */
public class Matchmaker implements MyInvocationHandler {

	
	private Person target;
	
	
	public Object getInstance(Person target) {
		this.target = target;
		Class clazz = target.getClass();
		System.out.println("被代理对象的class是 :" + clazz);
		 return MyProxy.newProxyInstance(new MyClassLoader(), clazz.getInterfaces(), this);
	}
	
	
	
	
	@Override
	public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
		
		System.out.println(proxy.getClass());
		
		System.out.println("开始进行匹配");
		System.out.println("------------------------");
		
		// 方法的执行
		method.invoke(this.target, args);
		System.out.println("------------------------");
		System.out.println("如果合适的话,就干该干的吧...");
		return null;
	}

}
